﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation.Behaviours
{
    public class EnergyBallBehaviour : Behaviour
    {
        protected const float  RANDOMNESS = 700;
        protected WorldProperties worldProperties;
        protected EnergyBall owner;
        protected float weight;
        public float getWeight() { return this.weight; }

        public EnergyBallBehaviour(WorldProperties worldProperties, EnergyBall owner, float weight)
        {
            this.worldProperties = worldProperties;
            this.owner = owner;
            this.weight = weight;
        }

        public Vector2 RunBehaviour()
        {
            if (owner.Target != null)
            {
                Vector2 velocity = (owner.Target.Position - owner.Position);
                velocity.Normalize();
                velocity *= owner.MaxSpeed;
                velocity.X += RANDOMNESS * (float)(worldProperties.Random.NextDouble() - 0.5);
                velocity.Y += RANDOMNESS * (float)(worldProperties.Random.NextDouble() - 0.5);
                return velocity;
            }
            else
            {
                return Vector2.Zero;
            }
        }
    }
}
